import { commonTableOptions } from "@/utils/options"

export function tableOption () {
  const self = this;
  return {
    ...commonTableOptions,
    span: 24, // 实现添加/修改form上下排列为1列
    dialogWidth: "50%",
    // height: self?.documentHeight - 500,
    labelPosition: "right",
    addBtn: true,
    saveBtnIcon: " ",
    cancelBtnIcon: " ",
    editBtnIcon: " ",
    delBtnIcon: " ",
    updateBtnIcon: " ",
    addBtnIcon: " ",
    header: true,
    viewBtn: true,
    editBtn: true,
    filterBtnNew: false,
    delBtn: true,
    viewBtnText: '详情',
    viewBtnIcon: " ",
    viewTitle: '人员详情',
    searchMenuSpan: 24,
    // selection: true,
    // selectionWidth: 70,
    // selectionFixed: true,
    column: [
      {
        label: "姓名",
        prop: "realName",
        hide: false,

        rules: [
          { required: true, message: "姓名不能为空", trigger: "blur" },
          {
            min: 2,
            max: 20,
            message: "长度在 2 到 20 个字符",
            trigger: "blur",
          },
        ],
        search: true,
        overHidden: true,
      },
      {
        label: "手机号",

        prop: "mobile",
        hide: false,

        rules: [
          { required: true, message: "手机号不能为空", trigger: "change" },
          {
            required: true,
            validator: this.$validator.isMobile,
            trigger: "change",
          },
        ],
        control: (val, form) => {
          if (form.mobile && form.id) {
            return {
              mobile: {
                disabled: true,
              },
            };
          }
          return {
            mobile: {
              disabled: false,
            },
          };
        },
      },
      {
        label: "部门",
        prop: "departName",
        hide: false,
        overHidden: true,
        addDisplay: false, // 添加时，去除该字段
        editDisplay: false, // 修改时，去除该字段
      },
      {
        label: "部门",
        prop: "departId",
        search: true,
        cascader: ["postId"],
        value: [],
        hide: true,
        type: "tree",
        rules: [{ required: true, message: "请选择部门", trigger: "change" }],
        props: {
          // 定义树结构的label和value字段
          label: "name",
          value: "id",
          children: "childList",
        },
        dicData: self.deptList,
        viewDisplay: false
      },
      {
        label: "主要职位",
        prop: "postName",
        hide: false,
        overHidden: true,
        addDisplay: false, // 添加时，去除该字段
        editDisplay: false, // 修改时，去除该字段
      },
      {
        label: "主要职位",
        prop: "postId",
        hide: true,
        search: "true",
        type: "select",
        filterable: true,
        viewDisplay: false,
        rules: [{ required: true, message: "请选择职位", trigger: "change" }],
        // dicData: this.postList,
        // dicMethod:this.filterPost,
        dicUrl: `${this.$apiroot}/supervise/post/queryList?deptId={{departId}}`,
        dicFormatter: (data) => {
          if (data.result && data.result.length) {
            return data.result.map((val) => {
              return {
                postName: val.name,
                id: val.id,
              };
            });
          } else {
            return [];
          }
        },
        props: {
          // 定义树结构的label和value字段
          label: "postName",
          value: "id",
        },
      },

      {
        label: "兼任职位",
        prop: "namelist",
        hide: false,
        // formatter: (val) => {
        //   console.log("🤡 ~ val:-( ", val)

        //   if (val && val.postNameList && val.postNameList.length > 0) {
        //     return val.postNameList.toString()
        //   }
        // },
        overHidden: true,
        addDisplay: false, // 添加时，去除该字段
        editDisplay: false, // 修改时，去除该字段
      },
      {
        label: "兼任职位",
        prop: "postIds",
        value: [],
        hide: true,
        type: 'select',
        filterable: true,
        multiple: true,
        // leafOnly: true,
        dicData: self.choosePostList,
        props: {
          // 定义树结构的label和value字段
          label: "name",
          value: "id",
        },
        viewDisplay: false
      },
      // {
      //   label: "角色",
      //   hide: false,
      //   prop: "rolelist",
      //   // formatter: (val) => {
      //   //   if (val && val.roleName && val.roleName.length > 0) {
      //   //     return val.roleName.toString()
      //   //   }
      //   // },
      //   overHidden: true,
      //   addDisplay: false, // 添加时，去除该字段
      //   editDisplay: false, // 修改时，去除该字段
      // },
      {
        label: "角色",
        search: false,
        prop: "roles",
        value: [],
        overHidden: true,
        type: "select",
        multiple: true,
        rules: [{ required: true, message: "请选择角色", trigger: "change" }],
        dicData: self.roleList,
        props: {
          // 定义树结构的label和value字段
          label: "roleName",
          value: "id",
        },
      },
      {
        label: "账号状态",
        search: true,
        type: "select",
        prop: "tenantStatus",
        slot: true,
        hide: false,
        overHidden: true,
        editDisplay: false,
        addDisplay: false,
        dicData: [
          // 0停用，1：启用，2未激活"
          { label: "已停用", value: 0 },
          { label: "正常", value: 1 },
        ],
      },
      {
        label: "创建时间",
        prop: "createTime",
        hide: false,
        type: "datetime",
        format: "yyyy-MM-dd HH:mm:ss",
        valueFormat: "yyyy-MM-dd HH:mm:ss",
        editDisplay: false,
        addDisplay: false,
        width: 200,
      },

    ]
  }
}
